package com.wjn.basic.shejimoshi.factory;

/**
 * 普通工厂模式，发送信息，一个发送邮件一个发送短信，通过工厂来获取
 */
public class SendFactory {

    public Sender produce(String type) {
        if ("mail".equals(type)) {
            return new MailSender();
        } else if ("sms".equals(type)) {
            return new SmsSender();
        } else {
            System.out.println("请输入正确的类型!");
            return null;
        }
    }

    public static void main(String[] args) {
        SendFactory sendFactory=new SendFactory();
        Sender sender=sendFactory.produce("sms");
        sender.send();
    }

}
